package com.zr.eim.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zr.common.annotation.Log;
import com.zr.common.core.controller.BaseController;
import com.zr.common.core.domain.AjaxResult;
import com.zr.common.enums.BusinessType;
import com.zr.eim.domain.EimDataNucleicAcidCheck;
import com.zr.eim.service.IEimDataNucleicAcidCheckService;
import com.zr.common.utils.poi.ExcelUtil;
import com.zr.common.core.page.TableDataInfo;

/**
 * 核酸检查任务Controller
 * 
 * @author peihang
 * @date 2022-10-21
 */
@RestController
@RequestMapping("/eim/check")
public class EimDataNucleicAcidCheckController extends BaseController
{
    @Autowired
    private IEimDataNucleicAcidCheckService eimDataNucleicAcidCheckService;

    /**
     * 查询核酸检查任务列表
     */
    @PreAuthorize("@ss.hasPermi('eim:check:list')")
    @GetMapping("/list")
    public TableDataInfo list(EimDataNucleicAcidCheck eimDataNucleicAcidCheck)
    {
        startPage();
        List<EimDataNucleicAcidCheck> list = eimDataNucleicAcidCheckService.selectEimDataNucleicAcidCheckList(eimDataNucleicAcidCheck);
        return getDataTable(list);
    }

    /**
     * 导出核酸检查任务列表
     */
    @PreAuthorize("@ss.hasPermi('eim:check:export')")
    @Log(title = "核酸检查任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EimDataNucleicAcidCheck eimDataNucleicAcidCheck)
    {
        List<EimDataNucleicAcidCheck> list = eimDataNucleicAcidCheckService.selectEimDataNucleicAcidCheckList(eimDataNucleicAcidCheck);
        ExcelUtil<EimDataNucleicAcidCheck> util = new ExcelUtil<EimDataNucleicAcidCheck>(EimDataNucleicAcidCheck.class);
        util.exportExcel(response, list, "核酸检查任务数据");
    }

    /**
     * 获取核酸检查任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('eim:check:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(eimDataNucleicAcidCheckService.selectEimDataNucleicAcidCheckById(id));
    }

    /**
     * 新增核酸检查任务
     */
    @PreAuthorize("@ss.hasPermi('eim:check:add')")
    @Log(title = "核酸检查任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EimDataNucleicAcidCheck eimDataNucleicAcidCheck)
    {
        return toAjax(eimDataNucleicAcidCheckService.insertEimDataNucleicAcidCheck(eimDataNucleicAcidCheck));
    }

    /**
     * 修改核酸检查任务
     */
    @PreAuthorize("@ss.hasPermi('eim:check:edit')")
    @Log(title = "核酸检查任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EimDataNucleicAcidCheck eimDataNucleicAcidCheck)
    {
        return toAjax(eimDataNucleicAcidCheckService.updateEimDataNucleicAcidCheck(eimDataNucleicAcidCheck));
    }

    /**
     * 删除核酸检查任务
     */
    @PreAuthorize("@ss.hasPermi('eim:check:remove')")
    @Log(title = "核酸检查任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(eimDataNucleicAcidCheckService.deleteEimDataNucleicAcidCheckByIds(ids));
    }

    /**
     * 查询当日核酸检测数
     * 需求模块：数据大屏
     */
    @PreAuthorize("@ss.hasPermi('eim:check:query')")
    @PostMapping("/getCurrentNum")
    public AjaxResult getCurrentNum()
    {
        return AjaxResult.success(eimDataNucleicAcidCheckService.getCurrentNum());
    }
}
